package com.algrithom.pointer;

import java.util.Arrays;

/**
 * 344. 反转字符串
 * 
 * @author think
 */
public class Solution6 {
    
    public static void main(String[] args){
        char[] chs = new char[]{'h','e','l','l','o'};
        Solution6 solution6 = new Solution6();
        solution6.reverseString(chs);
        System.out.println(Arrays.toString(chs));
    }
    
    public void reverseString(char[] s){
        int len = s.length;
        int left = 0;
        int right = len - 1;
        while (left < right) {
            s[left] = (char)(s[left] ^ s[right]);
            s[right] = (char)(s[left] ^ s[right]);
            s[left] = (char)(s[left] ^ s[right]);
            left++;
            right--;
        }
    }
}
